package com.project.controller;

import com.project.bean.OrderBean;
import com.project.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("order")
@RestController
public class OrderController {
    @Autowired
    private IOrderService orderService;


    @RequestMapping("addOrder")
    public String addOrder(OrderBean orderBean) {
        orderService.addOrder(orderBean);
        return "ok";
    }

    @RequestMapping("findByUser/{userName}")
    public List<OrderBean> findByUser(@PathVariable("userName") String userName) {
        List<OrderBean> orderBeanList = orderService.findByUser(userName);
        return orderBeanList;
    }
}
